package com.bamboo.mcp.server.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springaicommunity.mcp.annotation.McpTool;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Service
public class TimeService {
    private static final Logger logger = LoggerFactory.getLogger(TimeService.class);


    @McpTool(name = "currentTime", description = "获取当前时间，格式为：yyyy-MM-dd HH:mm:sss")
    public String getCurrentTime() {
        logger.info("getCurrentTime");
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String result = now.format(formatter);
        logger.info("getCurrentTime,result:{}", result);
        return result;
    }
}
